<?php
//必须参数keyid,site
require_once dirname(__FILE__).'/include/common.inc.php';

$keyid=$_GET["keyid"];
$site=$_GET["site"];


$sql="select count(*) as countx from caiji_keyword";
$re=$db->query($sql);
$re=$db->fetch_array($re);
$countx=$re[countx];
if($keyid<1 || $keyid>$countx)
{
	echo $keyid.'-'.$countx;
	return;
}
else
{

$sql="select title from caiji_keyword limit ".$keyid;
$re=$db->query($sql);
$keyinfo;
while($r=$db->fetch_array($re))
{
	$keyinfo=$r;
}

//echo $keyinfo[tag];

//$url="http://news.baidu.com/ns?from=news&cl=2&bt=1241798400&y0=2009&m0=5&d0=9&y1=2009&m1=5&d1=9&et=1241884799&q1=&submit=%B0%D9%B6%C8%D2%BB%CF%C2&q3=%D6%D0%BB%AA&q4=&mt=0&lm=&s=2&begin_date=2009-5-9&end_date=2009-5-9&tn=newsdy&ct1=1&ct=1&rn=20&class=0&q6=sina.con";

$para="site:".$site." ".$keyinfo[title];
$para=urlencode(iconv("UTF-8", "gb2312", $para));


$time1=strtotime(date("Y-m-d"));
$time2=strtotime(date("Y-m-d",strtotime("+1 days")));

$url="http://news.baidu.com/ns?word=".$para."&pn=100&cl=1&bt=".$time1."&et=".$time2;

//echo $url;
header("location:".$url); 

}
?>